import request from '@/utils/request'
const baseURL_notice = '/message/notice'
const baseURL_message = '/message'
export default {
  // 根据userId获得聊天数据
  getMessage(userId) {
    return request({
      url: baseURL_message + '/getById',
      method: 'GET',
      params: {
        userId
      }
    })
  },
  // 添加聊天记录
  saveMessage(data, messageId, connectId) {
    return request({
      url: baseURL_message + '/saveMessage',
      method: 'POST',
      data,
      params: {
        messageId,
        connectId
      }
    })
  },
  // 创建会话
  createConnect(messageId, connectId, postsId) {
    return request({
      url: baseURL_message + '/createConnect',
      method: 'POST',
      params: {
        messageId,
        connectId,
        postsId
      }
    })
  },
  // 判断当前用户的会话是否存在，如果不存在就创建
  connectIsExist(messageId, connectId, postsId) {
    return request({
      url: baseURL_message + '/connectIsExist',
      method: 'POST',
      params: {
        messageId,
        connectId,
        postsId
      }
    })
  },
  clearNumber(messageId, connectId) {
    return request({
      url: baseURL_message + '/clearNumber',
      method: 'GET',
      params: {
        messageId,
        connectId
      }
    })
  },
  getAll(userId, page, size) {
    return request({
      url: baseURL_notice + '/all',
      method: 'GET',
      params: {
        userId,
        page,
        size
      }
    })
  },
  unread(userId, page, size) {
    return request({
      url: baseURL_notice + '/unread',
      method: 'GET',
      params: {
        userId,
        page,
        size
      }
    })
  },
  read(userId, page, size) {
    return request({
      url: baseURL_notice + '/read',
      method: 'GET',
      params: {
        userId,
        page,
        size
      }
    })
  },
  setRead(noticeId) {
    return request({
      url: baseURL_notice + '/setRead',
      method: 'POST',
      data: noticeId
    })
  },
  setReadBluk(noticeIdList) {
    return request({
      url: baseURL_notice + '/setRead/bluk',
      method: 'POST',
      data: noticeIdList
    })
  },
  deleteBluk(noticeIdList) {
    return request({
      url: baseURL_notice + '/delete/bluk',
      method: 'POST',
      data: noticeIdList
    })
  },
  getCount(userId) {
    return request({
      url: baseURL_notice + '/count',
      method: 'GET',
      params: {
        userId
      }
    })
  }
}
